package presentation;

import java.awt.Font;
import java.text.DecimalFormat;
import java.util.Observable;
import java.util.Observer;

import javax.swing.JLabel;

/**
 * 
 * @author Jakob Witte Larsen
 * @version 1.39, 02/28/97
 */
public class PRegisterValue extends JLabel implements Observer {
	private static final long serialVersionUID = 1L;
	private Font font = new Font("Arial",Font.PLAIN,16);
	private DecimalFormat df = new DecimalFormat("#.##");
	
	public PRegisterValue(String text, int horizontalAlignment) {
		super(text, horizontalAlignment);
		this.setFont(font);
	}	
	
	public PRegisterValue(String text, String tooltip) {
		setText(text);
		
		this.setFont(font);
		this.setToolTipText(tooltip);
	}

	@Override
	public void update(Observable obj, Object arg) {
		if (arg instanceof Number) {
			this.setText("" + df.format(arg));
		} else {
			this.setText("" + arg);
		}
	}
}

